package com.example.demo.offer;

import java.util.Deque;
import java.util.LinkedList;

public class Offer45 {
    public static void main(String[] args) {

    }

    public int findBottomLeftValue(TreeNode root) {
        Deque<TreeNode> queue = new LinkedList<>();
        queue.offer(root);
        int ret = 0;
        while (!queue.isEmpty()){
            TreeNode poll = queue.poll();
            if(poll.right != null){
                queue.offer(poll.right);
            }
            if(poll.left != null){
                queue.offer(poll.left);
            }
            ret = poll.val;
        }
        return ret;
    }
}
